const fs = require("fs");
require("http")
  .createServer((req, res) => {
    // 根据客户端发来的请求地址响应相应的html文件
    const { url } = req;
    const filePath = `${__dirname}/${url.slice(1)}.html`;
    fs.readFile(filePath, (err, data) => {
      res.setHeader("Content-Type", "text/html; charset=utf-8");
      res.end(data);
    });
  })
  .listen(3000, () => {});
